﻿using System;
using System.Drawing.Printing;
using System.Linq;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.Skins;

namespace B2BAktarim
{
    public partial class frmAyar : XtraForm
    {
        public frmAyar()
        {
            InitializeComponent();
        }

        private void frmAyar_Load(object sender, EventArgs e)
        {
            for (int i = 1; i < vGridControl1.Rows.Count; i++)
            {
                if (!string.IsNullOrEmpty(vGridControl1.Rows[i].Properties.FieldName))
                {
                    vGridControl1.Rows[i].Properties.Value = Convert.ToString(Settings.Instance.GetValue((Information)Enum.Parse(typeof(Information), vGridControl1.Rows[i].Properties.FieldName)));
                }
            }
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            for (int i = 1; i < vGridControl1.Rows.Count; i++)
            {
                if (vGridControl1.Rows[i].Properties.Value != null)
                    Settings.Instance.AddItems((Information)Enum.Parse(typeof(Information), vGridControl1.Rows[i].Properties.FieldName), vGridControl1.Rows[i].Properties.Value.ToString());
            }

            Settings.Instance.Close();
            this.Close();
        }

        private void frmAyar_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }
    }
}
